.TH std::mdspan::operator[] 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::mdspan::operator[] \- std::mdspan::operator[]

.SH Synopsis
   template< class... OtherIndexTypes >
   constexpr reference operator[]( OtherIndexTypes... indices )       \fB(1)\fP (since C++23)
   const;
   template< class OtherIndexType >

   constexpr reference operator[]                                     \fB(2)\fP (since C++23)

       ( std::span<OtherIndexType, rank()> indices ) const;
   template< class OtherIndexType >

   constexpr reference operator[]                                     \fB(3)\fP (since C++23)

       ( const std::array<OtherIndexType, rank()>& indices ) const;

   Returns a reference to the indices^th element of the mdspan.

   1) Equivalent to return acc_.access(ptr_,
   map_(static_cast<index_type>(std::move(indices))...));.
   This overload participates in overload resolution only if:
     * (std::is_convertible_v<OtherIndexTypes, index_type> && ...) is true,
     * (std::is_nothrow_constructible_v<index_type, OtherIndexTypes> && ...) is true,
       and
     * sizeof...(OtherIndexTypes) == rank() is true.
   Let I be extents_type::index-cast(std::move(indices)). Then the behavior is
   undefined if I is not a multidimensional index in extents(), i.e., map_(I) <
   map_.required_span_size() is false.
   2,3) Let P be a parameter pack such that std::is_same_v<make_index_sequence<rank()>,
   index_sequence<P...>> is true, then the operator is equivalent to return
   operator[](extents_type::index-cast(std::as_const(indices[P]))...);.
   This overload participates in overload resolution only if:
     * std::is_convertible_v<const OtherIndexType&, index_type> is true, and
     * std::is_nothrow_constructible_v<index_type, const OtherIndexType&> is true.

.SH Parameters

   indices - the indices of the element to access

.SH Return value

   A reference to the element.

.SH Example

    This section is incomplete
    Reason: no example

   Defect reports

   The following behavior-changing defect reports were applied retroactively to
   previously published C++ standards.

      DR    Applied to              Behavior as published              Correct behavior
   LWG 3974 C++23      overloads (2,3) did not apply                   applies
                       extents_type::index-cast

.SH See also

    This section is incomplete

.SH Categories:
     * Todo no example
     * Todo without reason
